/**
 * @author wangpeizhi
 */
import request from '@/utils/request'

/**
 * 字典
 */
export function getDictByCode(dictCode) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/sysDictionary/getDictByCode',
    method: 'get',
    params: { dictCode }
  })
}
/**
 * 获取角色列表
 * @param {*} query
 */
export function roleList(query) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/role/queryMechanismPage',
    method: 'get',
    params: query
  })
}
/**
 * 创建角色
 * @param {*} data
 */
export function createRole(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/role/insert',
    method: 'post',
    data
  })
}
/**
 * 删除角色
 * @param {*} ids
 */
export function deleteRole(ids) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/role/delete',
    method: 'get',
    params: {
      ids
    }
  })
}
/**
 * 更新角色
 * @param {*} data
 */
export function updateRole(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/role/update',
    method: 'post',
    data
  })
}
/**
 * 根据搜索条件查询组织树
 * @param {*} query
 */
export function roleListByName(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/orgInfo/getOrgTreeByName',
    method: 'post',
    data
  })
}
/**
 * 获取权限树
 */
export function getTreeAndSuper(parentId) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/orgInfo/getLeaf',
    method: 'get',
    params: {
      parentId
    }
  })
}

/**
 * 查询模块权限树
 */
export function queryMenu(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: 'backend/menu/queryMenu',
    method: 'post',
    data
  })
}
/**
 * 保存角色权限
 * @param {*} data
 * @param {*} data
 */
export function saveMenu(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: 'backend/role/insertRoleMenus',
    method: 'post',
    data
  })
}
/**
 * 角色现有权限
 * @param {*} data
 */
export function getData(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: 'backend/role/queryRoles',
    method: 'post',
    data
  })
}
/**
 * 异步组织部门树
 */
export function getComAndOrgTree(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/orgInfo/queryOrgAndDep',
    method: 'post',
    data
  })
}
/**
 * 异步new企业部门树
 */
export function getNewTreeData(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/orgInfo/getOrgAndDepTreeByName',
    method: 'post',
    data
  })
}
